<?php
/**
 * myAsyncValidate.php
 * 
 * (C) 2009, tetsuya.odaka(EzoGP).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* 非同期のvalidationを行う
	      
		author	; t.odaka
		date	; 2009/4/20

		requestパラメータとして、
			opt;　検証のオプション
			val; 検証対象の値
		の２つを受け取り、Validator.class.phpのvalidateメソッドによって検証を行う。

*/

include("../Myznala/MyValidator.class.php");
require("../Myznala/debugLog.php");

/*
//$myDebugLog->debug(var_dump($_POST)); // Debugログ
*/

switch($_SERVER['REQUEST_METHOD']) {
	case 'GET'	: $rMethod = &$_GET; break;
	case 'POST'	: $rMethod = &$_POST; break;
	default:
}
//$myDebugLog->debug("req_method: ".$_SERVER['REQUEST_METHOD']); // Debugログ

// リクエストからlocaleを取り出す。
$locale 
	= substr(strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']),0,2);
//$myDebugLog->debug("locale: ".$locale); // Debugログ

// MyValidatorをインスタンス化する。
$valObj = new MyValidator();

$opt = $rMethod['opt'];
$val = $rMethod['val'];
//$myDebugLog->debug("opt: ".$opt); // Debugログ
//$myDebugLog->debug("val: ".$val); // Debugログ

$ret = $valObj->validate($locale, $opt , $val);

/*
foreach ($_SERVER as $key => $value) {
//	$myDebugLog->debug($key.'; '.$value); // Debugログ
}
*/

// 結果の返却
header("Content-Type:text/plain");
echo $ret;

?>